package com.xuecheng.content.api.controller;

import com.xuecheng.content.model.dto.BindTeachPlanMediaDto;
import com.xuecheng.content.model.dto.SaveTeachPlanDto;
import com.xuecheng.content.model.dto.TeachPlanDto;
import com.xuecheng.content.services.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:王亚栋
 * @Date: 2023/7/9 下午5:06
 * @Version:1.0
 */
@Api(value = "查询课程计划管理",tags = "查询课程计划管理")
@RestController
public class TeachPlanController {

    @Autowired
    private TeachplanService teachplanService;

    @ApiOperation("查询课程计划树形结构")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId){

        return teachplanService.findTeachPlanTree(courseId);
    }

    @ApiOperation("课程计划创建或者修改")
    @PostMapping("/teachplan")
    public void saveTeachPlan(@RequestBody SaveTeachPlanDto saveTeachPlanDto){

        teachplanService.saveTeachPlan(saveTeachPlanDto);

    }

    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachPlanMediaDto bindTeachPlanMediaDto){


        teachplanService.associationMedia(bindTeachPlanMediaDto);
    }

}
